package com.lp.service.impl;

import com.lp.dao.SceneryListDao;
import com.lp.po.PagingVO;
import com.lp.po.SceneryList;
import com.lp.service.SceneryListService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SceneryListServiceImpl implements SceneryListService {
    @Resource
    private SceneryListDao sceneryListDao;
    @Override
    public int getSceneryListCount() throws Exception {
        return sceneryListDao.count();
    }
    @Override
    public List<SceneryList> findSceneryList(Integer toPageNo) {
        PagingVO pagingVO = new PagingVO();
        pagingVO.setToPageNo(toPageNo);
        List<SceneryList> list=sceneryListDao.findAll(pagingVO);
        return list;
    }

    @Override
    public SceneryList findById(Integer sceneryid) {
        return sceneryListDao.findById(sceneryid);
    }

    @Override
    public void updataSceneryname(Integer sceneryid, String sceneryname,String iconpath) {
        sceneryListDao.updataname(sceneryid,sceneryname,iconpath);
    }

    @Override
    public boolean save(SceneryList sceneryList) {
        SceneryList slist = sceneryListDao.selectSceneryname(sceneryList.getSceneryid());
        if (slist == null) {
            sceneryListDao.insert(sceneryList);
            return true;
        }
        return false;
    }

    @Override
    public void delectSceneryList(Integer sceneryid) {
        sceneryListDao.removeById(sceneryid);
    }

    @Override
    public List<SceneryList> findAll() {
        List<SceneryList> list=sceneryListDao.findAllWithoutPage();
        return list;
    }


    /***************************微信控制端*******************************************/
    @Override
    public List<SceneryList> wxfindSceneryList() {
        List<SceneryList> list=sceneryListDao.wxfindAll();
        return list;
    }


}
